package sg.edu.nus.iss.billing.datastore.impl;

import java.util.HashMap;
import java.util.Map;

import sg.edu.nus.iss.billing.entity.BaseEntity;

/**
 * generate id increment, just for inner use
 * @author wdy
 *
 */
final class IncrementIDGenerator extends BaseEntity {
	
	private static final long serialVersionUID = -7341898916563764444L;
	
	private Map<String, Integer> container = new HashMap<String, Integer>();
	
	public String getId(){
		return "1";
	}
	
	public Integer generateID(final String className){
		if(container.containsKey(className)){
			Integer i = container.get(className);
			container.put(className, i+1);
			return i+1;
		} else {
			container.put(className, 1);
			return 1;
		}
	}

	@Override
	public String toString() {
		return "IncrementIDGenerator [map=" + super.toString() + "]";
	}
	
	
}

